%%Read Data from .csv file
data= dlmread('2.csv',',',2,0);
l= length(data);
x= data(:,1);
y= data(:,2);
freq = 1/(x(2)-x(1));
figure
subplot(2,1,1)
plot (x,y)
xlabel('Time(s)')
ylabel('Amplitude (V)')

%% Choose periodic data from the csv file 
x1= data(407:504,1);
y1= data(407:504,2);
l1=length(x1);

%% Do FFT on the data being analysed

NFFT= 2^nextpow2(l1); % length of the FFT
Y= fft(y1,NFFT);
Y = Y(1:NFFT/2);
my = abs(Y);
f = (0:(NFFT/2)-1)*freq/NFFT; % frequency vector
subplot(2,1,2)
plot(f,my)
xlabel('Frequency (Hz)')
ylabel('Power')
grid